//
//  StringExten.swift
//  AESOLAR_IOS
//
//  Created by Bin Tang on 2024/10/11.
//  Copyright © 2024 Mr.Wang. All rights reserved.
//

import UIKit


class AEStringExten: NSObject {
    @objc static func localizedValue(key: String) -> String {
        var languagePath = "en.lproj"
        
        if let userSelectLanguage = AppCache.shared.object(for: APPUserDefault.self).userSelectLanguage {
            switch userSelectLanguage {
            case .chinese:
                languagePath = "zh-Hans.lproj"
            case .english:
                languagePath = "en.lproj"
            case .de:
                languagePath = "de.lproj"
            case .vi:
                languagePath = "vi.lproj"
            }
        }
        
        if let path = Bundle.main.path(forResource: languagePath, ofType: nil),
            let bundle = Bundle.init(path: path) {
            return bundle.localizedString(forKey: key, value: nil, table: "Localizable")
        }
        
        return Bundle.main.localizedString(forKey: key, value: nil, table: nil)
    }
}
